<template>
  <div class="order-detail-container">
    <div class="order-header">订单状态: {{orderStatus[orderDetail.ispaid]}}</div>
    <div class="order-body">
      <div class="order-info-container" @click="toHealthDetail">
        <div class="order-title">{{orderDetail.topackagename}}</div>
        <div class="order-info">
          <div class="user-name-container order-item">
            <div class="list-item-title">体检姓名</div>
            <div>{{orderDetail.touserpname}}</div>
          </div>
          <div class="test-time-container order-item">
            <div class="list-item-title">体检时间</div>
            <div class="time">{{orderDetail.reservetime.split(' ')[0]}}</div>
          </div>
          <div class="text-orderid-container order-item">
            <div class="list-item-title">订单编号</div>
            <div>{{orderDetail.orderid}}</div>
          </div>
          <div class="text-price-container order-item">
            <div class="list-item-title">支付金额</div>
            <div class="price">{{orderDetail.money}}元</div>
          </div>
        </div>
      </div>
    </div>
    <div class="order-footer" v-show="orderDetail.ispaid === '0'" @click="pay">
      去支付
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
import {http, payUrl} from 'api/main.js'

export default {
  data() {
    return {
      orderDetail: {
        reservetime: ''
      },
      orderStatus: ['未支付', '已支付']
    }
  },
  created() {
    this._getOrderDetail()
  },
  methods: {
    pay() {
      window.location.href=payUrl(this.orderDetail.orderid)
    },
    toHealthDetail() {
      console.log(1)
      this.$router.push({
        path: `/healthList/${this.orderDetail.topackageid}`
      })
    },
    _getOrderDetail() {
      console.log('id: ', this.$route.params.orderId)
      http('order', {
        id: this.$route.params.orderId
      }).then((res) => {
        console.log(res)
        this.orderDetail = res
      })
    }
  }
}
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
@import "~common/stylus/variable"

.order-detail-container
  position: fixed;
  top: 0
  left: 0
  right: 0
  bottom: 0
  z-index: 1000
  background-color: $color-background
  overflow: hidden;
  .order-header
    width: 100%
    background-color: #009fab
    height: 80px
    line-height: 80px
    color: #fff
    padding-left: 30px
  .order-body
    background-color: #fff
    margin: 20px 8px
    padding: 10px
    .order-info-container
      .order-title
        margin-top: 20px
        margin-bottom: 30px
      .order-info
        color: #666
        .order-item
          margin-top: 20px
        .user-name-container
          display: flex
        .test-time-container
          display: flex
          .time
            color: #009fab
        .text-orderid-container
          display: flex
        .text-price-container
          display: flex
          margin-bottom: 20px
          .price
            color: #ffa700
        .list-item-title
          width: 30%
  .order-footer
    background-color: #fff
    margin: 10px 8px 0 8px
    height: 35px
    line-height: 35px
    text-align: center


</style>
